<%@page import="forms.*, java.util.*" %>

<%@ taglib prefix="bean" uri="http://struts.apache.org/tags-bean" %>
<%@ taglib prefix="logic" uri="http://struts.apache.org/tags-logic" %>
<%@ taglib prefix="html" uri="http://struts.apache.org/tags-html" %>
<%@ page import="javax.sql.*"%>

<%@ page isELIgnored ="false" %> 

<html:html>

<font size="6">Provide degrees - Choose university</font>
<p>

<body>
	<ul style="list-style:none; margin: 0px;"> 
        <li><b>First Name: </b>${applicantDataBean.firstname} </li> 
        <li><b>Middle Name: </b>${applicantDataBean.middlename} </li>
        <li><b>Last Name: </b>${applicantDataBean.lastname} </li>
    </ul> <br>
    
    <b>Country of citizenship: </b>${applicantDataBean.country1} <br>
    <b>Country of residence: </b>${applicantDataBean.country2}
    
    <p>
    <b>Address: </b>${applicantDataBean.address} <br>
    <b>City: </b>${applicantDataBean.city} <br>
    
    <%
    // if "state" is NOT null, means they came from addressPage directly, means they ARE a US citizen
    if (request.getSession().getAttribute("state") != null)  {
    	out.println ("<b>State: </b>" + request.getSession().getAttribute("state"));
    }
    // else means they came from residencyPage, means they ARE NOT a US citizen
    else  {
    	out.println ("<b>Country Code: </b>" + request.getSession().getAttribute("countrycode"));
    }
    %>
    
    <br>
    <b>Zip Code: </b>${applicantDataBean.zipcode} <br>
    <b>Area Code: </b>${applicantDataBean.areacode} <br>
    <b>Telephone Number: </b>${applicantDataBean.telephonenumber}
    <p>
    
    
    
    
    
    
   	Current counter: <%= request.getSession().getAttribute("SessionCounter") %>
   	<br>
   	
   	
   	<%
	// if not the first time visiting, print out FIRST DEGREE's information
	if (!request.getSession().getAttribute("SessionCounter").equals(0))  {
		List<Degree> theDegreeArray = (LinkedList<Degree>) request.getSession().getAttribute("TheSessionDegreeArray");
		
		for (int i = 0; i < (Integer)(request.getSession().getAttribute("SessionCounter")); i++)  {
			
			Degree currentDegree = theDegreeArray.get(i);
			String currentLocationName = currentDegree.getLocation();
			String currentUniversityName = currentDegree.getUniversity();
			String currentMajorName = currentDegree.getMajor();
			String currentDegreeTitle = currentDegree.getDegreeTitle();
			String currentMonth = currentDegree.getMonth();
			String currentYear = currentDegree.getYear();
			String currentGPA = currentDegree.getGPA();
			String currentTranscriptFile = currentDegree.getMyFile().getFileName();
			out.println ("<br>" + "<b>Location of university: </b>" + currentLocationName + "<br>");
			out.println ("<b>Name of university: </b>" + currentUniversityName + "<br>");
			out.println ("<b>Major: </b>" + currentMajorName + "<br>");
			out.println ("<b>Degree title: </b>" + currentDegreeTitle + "<br>");
			out.println ("<b>Month: </b>" + currentMonth + "<br>");
			out.println ("<b>Year: </b>" + currentYear + "<br>");
			out.println ("<b>GPA: </b>" + currentGPA + "<br>");
			out.println ("<b>Transcript file: </b>" + currentTranscriptFile + "<br>");
		}
	}
	else
	{
	}
    %>
	
	<%
	List<Degree> theDegreeArray;
	if (session.getAttribute("TheSessionDegreeArray") != null)
	{
		// retrieve list from session attribute if it exists
		theDegreeArray = (LinkedList<Degree>) session.getAttribute("TheSessionDegreeArray");
	}
	else
	{
		// create the list otherwise
		theDegreeArray = new LinkedList<Degree>();
	}
		
	theDegreeArray.add (new Degree());
	Integer currentCount = (Integer)(session.getAttribute("SessionCounter"));
	theDegreeArray.get(currentCount).setLocation ((request.getParameter("locationName")).toString().replace('_', ' '));
	session.setAttribute ("TheSessionDegreeArray", theDegreeArray);
	%>
    
    
    <%	
    String currentLocationName = theDegreeArray.get(currentCount).getLocation().replace('_', ' ');
	out.println ("<br>" + "<b>Location of university: </b>" + currentLocationName);%>
    
    <p>
   	Please provide your degree university information.
   	<p>
	
	
	<%
   	RowSet crsUniversities = (RowSet) request.getAttribute("crsUniversities");
	RowSet crsCountUniv = (RowSet) request.getAttribute("crsCountUniv");
	// Integer count = (Integer) request.getAttribute("count");
	%>
	
	
	<table cellpadding=0 cellspacing=0 border=0><tr>
	<td width=40% valign=top>
			
	<%	
	//crsUniversities.next();
	crsCountUniv.next();
	Integer size = crsCountUniv.getInt("count");
	//String univCountQuery = request.getAttribute("univCountQuery").toString();
	
	// crsUniversitiesCount.next();
	
          	//Integer size = count;
          	
          	if (size == 1){
          		crsUniversities.next();
          		%>
				<html:link action="/showDegreeDisciplinePage">
	     			<html:param name="universityName" value="<%= crsUniversities.getString(\"university_name\")%>"/> 
	     			<%= crsUniversities.getString("university_name")%>
	     		</html:link><br><%
          		   		
          	}
          	
          	else{
          		
          	
			for (int i=0; i<size/3; i++){
				crsUniversities.next();
          		%>
				<html:link action="/showDegreeDisciplinePage">
	     			<html:param name="universityName" value="<%= crsUniversities.getString(\"university_name\")%>"/> 
	     			<%= crsUniversities.getString("university_name")%>
	     		</html:link><br><%
			}
			%>
			</td>
			<td width=40% valign=top>
			<%
			for (int i=(size/3); i<2*(size/3); i++){
          		%>
				<html:link action="/showDegreeDisciplinePage">
	     			<html:param name="universityName" value="<%= crsUniversities.getString(\"university_name\")%>"/> 
	     			<%= crsUniversities.getString("university_name")%>
	     		</html:link><br><%
				crsUniversities.next();
			}
			%>
			<td width=40% valign=top>
			<%
			for (int i=2*(size/3); i<size; i++){
          		%>
				<html:link action="/showDegreeDisciplinePage">
	     			<html:param name="universityName" value="<%= crsUniversities.getString(\"university_name\")%>"/> 
	     			<%= crsUniversities.getString("university_name")%>
	     		</html:link><br><%
				crsUniversities.next();
			}
			%>
			</td>
			</tr></table>
			<%
          	}
          	
          	%>
	</td>
	</tr>
	</table>
	

</body>
</html:html>